<?php

$user_obj = new user_obj();
$expense_obj = new expense_obj();

if (!empty($_REQUEST['action'])){
    switch ($_REQUEST['action']) {
        case 'add_expense':
            
            $in_data = $_REQUEST['expense'];
            $in_data['from'] = base_obj::convertDateTo($in_data['from']);
            $result = $expense_obj->addExpense($in_data);
            
            if (error_obj::isError($result)){
                error_obj::setError($result, UNEXCEPTED);
            } else {
                base_obj::redirect(ROOT . '?input=fixed_expense&message=added');
            }
            break;
    }
}

$filter = array(
    'levels' => array(
        USER_TYPE_ADMIN, USER_TYPE_TECHNIC
    )
);

$GLOBALS['template_data']['users'] = $user_obj->getUsers("*", $filter, $GLOBALS['list_of_users_order']);
$GLOBALS['template_data']['prefill']['from'] = date("d/m/Y");
?>
